<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$tabs=array(
	array('op'=>'list','title'=>'月供标审核'),
);
if($_RQ['op']=='list'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>0);
	if($_RQ['mid']){
		$params['mid']=intval($_RQ['mid']);
		$return['params']['mid']=intval($_RQ['mid']);
	}
	//日志种类，1增加，0减少
	if(isset($_RQ['isadd'])){
		$params['isadd']=intval($_RQ['isadd']);
		$return['params']['isadd']=$_RQ['isadd'];
	}
	//时间范围
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['psize']){
		$_SESSION['psize']=$_RQ['psize'];
	}
	$psize = $_SESSION['psize']?:10;
	$list=pdo_getslice('jy_carfee_gongblog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['member']=cfc('core')->member_show($item['mid']);
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'月供标币记录','total'=>$total,'psize'=>$psize,'edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'mid','title'=>'会员id','type'=>'string'),
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('name'=>'isadd','title'=>'日志类型','type'=>'radio','options'=>'adds'),
			array('name'=>'fee','title'=>'个数','type'=>'string'),
			array('name'=>'remark','title'=>'备注','type'=>'string'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'modal','op'=>'check','title'=>'审核'),
		)),
		'search'=>array(
			array('type'=>'choose','width'=>15,'title'=>'会员id','name'=>'mid','action'=>'member.get_member','choose_title'=>'选择会员'),
			array('type'=>'time_range','width'=>18,'title'=>'创建时间','name'=>'createtime','help'=>''),
		),
	);
	$return['adds']=array('消耗','增加');	
	$return['htmls']=$htmls;	
	exi($return);
}
if($_RQ['op']=='check'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$logid=intval($post['id']);
		$status=intval($post['status']);
		if(!$status){
			exi('请选择审核通过还是不通过！','error');
		}
		$this->model('model')->check_gongblog($logid,$status,$post['checkmsg']);
		exi('审核成功！','','list');
	}
	$item=$this->get('gongblog',array('id'=>intval($_RQ['id'])));
	if(!$item){
		exi('指定记录不存在！','error');
	}
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'审核月供标记录',
		'edit'=>array(
			array('name'=>'status','title'=>'审核','type'=>'radio','options'=>'cheblog_status'),
			array('name'=>'checkmsg','title'=>'不通过原因','type'=>'text','show'=>array('status'=>2)),
		),
	);
	$return['cheblog_status']=$this->cheblog_status;
	exi($return);
}